package com.bookstore.mapper;

import com.bookstore.entity.Book;
import com.bookstore.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author Cofe
 * @Date 2022/4/17 8:26
 */
@Mapper
public interface BookMapper {
    //通过id查询某个图书
    Book findById(@Param("bid")int bid);

    //查询所有图书
    List<Book> findAllBook();

    //保存图书
    void insertBook(@Param("book_name")String book_name,@Param("book_type")String book_type,@Param("book_intro")String book_intro,
                    @Param("book_number")int book_number,@Param("book_balance")double book_balance,@Param("book_discount")double book_discount
            ,@Param("book_membalance")double book_membalance,@Param("book_pic")String imgname);

    //图书畅销榜
    List<Book> findBookTop();

    //图书畅销榜
    List<Book> findBookTopBalance(@Param("begin") int begin,@Param("size") int size);

    //修改图书数据
    Integer updateBook(@Param("bid")int bid,@Param("book_name")String book_name,@Param("book_type")String book_type,
                       @Param("book_intro")String book_intro, @Param("book_number")int book_number
            ,@Param("book_balance")double book_balance,@Param("book_discount")double book_discount,@Param("book_membalance")double book_membalance);

    //修改图书数据
    Integer updateBookNew(@Param("bid")int bid, @Param("book_number")int book_number,@Param("book_sale")double book_sale);

    //通过页数查询图书信息
    List<Book> selectByPage(@Param("begin") int begin,@Param("size") int size);

    //分页条件查询
    List<Book> selectByPageAndCondition(@Param("begin") int begin,@Param("size") int size,@Param("book") Book book);

    //记录总数据
    Integer selectTotalCount();

    //根据条件查询总记录数
    Integer selectTotalCountByCondition(@Param("book")Book book);

    //删除图书(不是下架,就是永久删除)
    Integer deletebook(@Param("bid") int bid);
}
